package com.edu.controller.fileupload;

import com.alibaba.fastjson.JSON;
import com.edu.utils.FileParse;
import com.edu.utils.ParamFormat;
import com.edu.utils.ResponseBody;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author ZCN
 * @Date 2021/11/14 21:39
 * @Version 1.0
 **/
// 用作文件存储（返回String文件的存储位置）
@WebServlet("/file/save")
@MultipartConfig
public class UploadServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 参数格式化
        ParamFormat.format(req, resp);
        // 调用文件存储工具类
        String fileindex = FileParse.filestorg(req);
        // 返回结果
        ResponseBody.success(resp,fileindex,0L,null);
    }
}
